<?php
$box_title= "Emails - Already Sent";

$box_contents  = "<div align=\"right\" class=\"top\"><a href=\"index.php?m=emails&a=index\">Emails - In Queue</a> <a href=\"index.php?m=emails&a=addedit\">Create New Emails</a></div>";
$box_contents .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\"  align=\"center\">";
$box_contents .= "<tr>";
$box_contents .= "<td>Email</td>";
$box_contents .= "<td>Subject</td>";
$box_contents .= "<td align=\"right\">Options</td>";
$box_contents .= "</tr>";

$temp =  sql_query("SELECT e.id, e.message_id, e.email, m.subject FROM emails AS e, messages AS m WHERE e.message_id=m.id AND e.sent='1' ORDER BY e.id DESC");
while($res = sql_fetch_row($temp)) {
    $box_contents .= "<td> &raquo; <a href=\"index.php?m=emails&a=view&id=".$res['id']."\">".$res['email']."</a></td>";
    $box_contents .= "<td><a href=\"index.php?m=messages&a=view&id=".$res['message_id']."\">".$res['subject']."</a></td>";
    $box_contents .= "<td align=\"right\">";
    $box_contents .= "<a href=\"index.php?m=emails&a=addedit&id=".$res['id']."\">[Edit]</a> ";
    $box_contents .= "<a onclick=\"javascript: return confirm('Are you sure to delete?');\" href=\"index.php?m=emails&a=delete&id=".$res['id']."\">[Delete]</a> ";
    $box_contents .= "</td></tr>";
}
$box_contents .= "</table>";
?>